 $(document).ready(function(){
        var buildPlate = function () {
            var _plateContainer = $('#plate_container');
            _plateContainer.children('.tr').remove();
            var plate = arguments[0];
            if (!plate || plate.length <= 0) { return; }
            var _tpl = _.template($("#plate_row").html())
            var _html = _tpl(plate);
            _plateContainer.append(_html);
        }
        //滚动条
        $(".slimscroll").slimScroll({
            height:'499',
            opacity: 0.3
        });    	//swiper
		var mySwiper = new Swiper ('.swiper-container',{
			loop:false,
			autoplay:3000,
			pagination: '.swiper-pagination',
			paginationClickable: true
		});
        // 绑定品类菜单事件
        $('[action=leftCategory]').click(function () {
            $('a.menu.active').removeClass('active');
            $(this).addClass('active');
            _categoryId = $(this).attr('data-id');
            changeCategory(_categoryId);
        });
        function changeCategory(_categoryId){
            if (_categoryId) {
            	$("#categoryId").val(_categoryId);
            	$("#formIdSearch").submit();
            }

        }
        function headerlogin(){
            $('.headerLogin').Qsubmit(null,function(msg){
                showModal(msg);
                $('.headerLogin').find('input[name=imgcode]').val('');
                $('.headerLogin').find('img[name=img]').click();
            });
        }
        $(function(){
            $('.headerLogin a[action=login]').on('click',headerlogin);
            $('.headerLogin').find('input').on('keydown',function(){
                if (event.keyCode == "13") {
                     $('a[action=login]').click();
                 }
            });
        });
        // 交易大厅品类下拉列表
        $('li[action="menu"]').mouseenter(function(){
            $(this).find("ul").fadeIn(500);
        }).mouseleave(function(){
            $(this).find("ul").fadeOut(500);
        })
        //移动版 下拉菜单
        $('a[action="my"]').click(function(){
            if($(".my-list").css("display")=="block"){
                $(".my-list").fadeOut(200);        
            }else{
                $(".my-list").fadeIn(500);
            }
            
        });
        $("body").click(function(event){
            if($('a[action="my"]').length>0){
                if(event.target!=$('a[action="my"]')[0] && !jQuery.contains($('a[action="my"]')[0], event.target)){

                    if($(".my-list").css("display")=="block"){

                        $(".my-list").fadeOut(200);

                    }
                }
            }
        });
        
   	 window.onresize = function(){
   			myChart.resize();
   		}
   	 
   	 var chartEl = document.getElementById('chart');
        var myChart = echarts.init(chartEl);
        var _left = '';
        var option = {
        		backgroundColor:'#CCC',
            title: {
                text: '行情走势图',
                x:'center',
                textStyle:{fontSize:'14px', color:"#479ADD"},
                textBaseline:'middle'
            },
            tooltip: {
                trigger: 'axis',
                formatter: function (name) {
                    if ($.isArray(name)) {
                        var _n = name[0].name.replace('false','');
                        var _v = name[0].value;
                        return _n + "<br/>4声母.com<br/>价格：" + _v;
                    }
                },
                axisPointer: {animation: false}
            },
            xAxis: [{
                boundaryGap : false,
                type: 'category',
                axisLabel:{
                    textStyle:{color:"#479ADD"},
                    formatter:function (value) {
                        return value.substr(5,6);
                    },
                    interval:function (index, value) {
                        if (value.indexOf('false') > 0) return false;
                        var _arr = value.split(" ");
                        if (_left == _arr[0]) return false;
                        _left = _arr[0];
                        return true;
                    },
                },
                splitLine: {show: false},
                data:xaxis_data,
            }],
            yAxis: [{
                type: 'value',
                scale: true,
                splitNumber:8,
                min: 0,
                boundaryGap: [10, '100%'],
                splitLine: {show: false},
                axisLabel:{
                    textStyle:{color:"#479ADD"},
                    formatter:function (value, index) {
                        if (value>999) {
                        	return value / 1000 + "K";
                        } 
                        return value;
                    }
                }
            }],
            series: [{
                name:'最高价',
                type:'line',
                data:yaxis_data,
                markPoint: {
                    data: [
                        {type: 'max',name:"最高价"},
                        {type: 'min',name:"最低价"}
                    ]
                },
                markLine: {
                    data: [
                        {type: 'average',name:"平均价"}
                    ]
                }
            }]
        };
        if (yaxis_data && yaxis_data.length > 0) {
            myChart.setOption(option, true);
        }
        
        //切换登录模式
        $('.signin-panel .switchTab').on('click',function(){
            $(this).parents(".signin-panel").find("."+$(this).attr("target")).siblings("[panel='true']").hide();
            $(this).parents(".signin-panel").find("."+$(this).attr("target")).show();
            $(this).siblings().removeClass('active');
            $(this).addClass('active');
        });
        $('a[action=login]').on('click',function(){
            $(this).parents("form").Qsubmit(null,function(msg){
                showModal(msg);
                $(this).parents("form").find('input[name=imgcode]').val('');
                $(this).parents("form").find('img[name=img]').click();
            });

        });
        $('.indexlogin').find('input').on('keydown',function(){
            if (event.keyCode == "13") {
                 $('.indexlogin a[action=login]').click();
             }
        });
        
        $("#18_timer6329").click(function(){
    		smsSend();
    	});
    });
 /**
  * 发送短信验证码
  */
 var smsSend=function(){
	 var obj=$("#18_timer6329");
	 var phone = $(obj.parents('form').find('[name=mobile]')[0]).val();
	 if(phone==null || phone.length==0) {
		 showModal('请输入正确格式的手机号码');
		 $(obj.parents('form').find('[name=mobile]')[0]).addClass("input-error");
		 return false;
	 } else if(phone.length==11) {
		 $(obj.parents('form').find('[name=mobile]')[0]).removeClass("input-error");
	 } 
	 var smsurl=$("#loginFormId").attr("action");
	 var len=smsurl.lastIndexOf("/");
	 smsurl=smsurl.substring(0,len);
	 smsurl=smsurl+"/sendLoginSms?mobile="+phone;
	 $.ajax({
		 type:'get',
		 url:smsurl,
		 success:function(data){
			 if(data.code=='error') {
				 showModal(data.info);
			 } else {
				 fun_timedown("18_timer6329",60);
				 showModal(data.info);
				 $("#18_timer6329").unbind("click");
			 }
		 }
	 });
 };
 
 /**
  * 倒计时
  */
 function fun_timedown(str,time) {
 	$("#"+str).text(time+"秒");
     time = time-1;
     if(time>=0){
         setTimeout("fun_timedown('"+str+"','"+time+"')",1000);
     }else{
     		$("#"+str).bind("click", function(){smsSend(str);});
     		$("#"+str).text("发送验证码");
     }
 }